# -*- coding: utf-8 -*-

import socket
hostname = 'www.baidu.com'
addr = socket.gethostbyname(hostname)
print addr

socket.getservbyname('domain')
socket.getaddrinfo('localhost',8080)

hostname = 'baidu.com'
infolist = socket.getaddrinfo(hostname, 0, 0, socket.SOCK_STREAM, 0, 
        socket.AI_ADDRCONFIG | socket.AI_V4MAPPED | socket.AI_CANONNAME,)
print (infolist)